<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Calendar</title>
		<meta http-equiv="Content-Type" content="text/html; charset=GBK">
		<script src="{$_G.tpldir}/js/jquery-latest.js"></script>
		
		<script type="text/javascript" src="{$_G.tpldir}/js/jquery-1.10.2.min.js"></script>
		<script type="text/javascript" src="{$_G.tpldir}/js/common.js"></script>
		<link href="{$_G.tpldir}/css/calendar-main.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="{$_G.tpldir}/js/bootstrap.min.js"></script>
		<script type="text/javascript" src="{$_G.tpldir}/js/jquery.dragsort.js"></script>
		<link rel="stylesheet" type="text/css" href="{$_G.tpldir}/css/bootstrap.min.css">
		
   		<script type="text/javascript">
   			{literal}
			function initMenu() {
				var block = $(".dots");
					block.addClass("clickable");
					$(".dropdown").removeClass("open");
					block.hover(function(){window.status = $(this)}, function(){window.status = ""});
				
				$('.open').hide();
				$('.open').css("cursor","default");
				$('.open li').css("cursor","default");
				$('.daybar').css("cursor","default");
				
				block.click(
					function() {
						$(this).parents('div').parents('div:eq(0)').find('.open').slideToggle('slow');	
						
					}
				);}
			$(document).ready(function() {initMenu();});
			
			$('#myModal').modal({
			  show: true
			})

			{/literal}
   		</script>		
	
	</head>
	<body>
		{include file='nav.html'}
		<div id="calendar">					
			<div id="calcontainer">
				<div id="calheader">
					<h1>Calendar</h1>
				</div>
				<div class="calendar-select">
						<form action="" method="post" id="missionform" name="missionform" onsubmit="sousuo()" >
					&nbsp;&nbsp;Project
					<select name="project_id" class="select" onchange="changeModules('','all')" >
					{ list module="project"  function="getProjectList" var="loop" type="options"  }
					{html_options options=$loop.list  selected=$magic.request.project_id}
					{/list}
					</select>
					
					
					&nbsp;&nbsp;Member
					<select name="user_id" class="select">
					{ list module="user"  function="getUserList" var="loop"  type="options" }
					{html_options options=$loop.list  selected=$magic.request.user_id}
					{/list}
					</select>
					&nbsp;&nbsp;Modules
					<select name="modules_id" class="select" id="modules_id">
					{ list module="modules"  function="getModulesList" var="loop"  project_id=$magic.request.project_id type="options" }
					{html_options options=$loop.list  selected=$magic.request.modules_id}
					{/list}
					</select>
			    	&nbsp;&nbsp;Status
					<select name="sub_status" class="select">
					{ list module="linkages"  function="getLinkagesList" var="loop"  type=1 }
					{html_options options=$loop.list  selected=$magic.request.sub_status}
					{/list}
					</select>
					&nbsp;&nbsp;Date
					<select name="year"  class="select">
						<option value="2014"  {if $magic.request.year ==2014} selected {/if}>2014</option>
						<option value="2015"  {if $magic.request.year ==2015} selected {/if}>2015</option>
						</select>
					<select name="month"  class="select">
						<option value="1" {if $magic.request.month ==1} selected {/if}>1</option>
						<option value="2" {if $magic.request.month ==2} selected {/if}>2</option>
						<option value="3" {if $magic.request.month ==3} selected {/if}>3</option>
						<option value="4" {if $magic.request.month ==4} selected {/if}>4</option>
						<option value="5" {if $magic.request.month ==5} selected {/if}>5</option>
						<option value="6" {if $magic.request.month ==6} selected {/if}>6</option>
						<option value="7" {if $magic.request.month ==7} selected {/if}>7</option>
						<option value="8" {if $magic.request.month ==8} selected {/if}>8</option>
						<option value="9" {if $magic.request.month ==9} selected {/if}>9</option>
						<option value="10" {if $magic.request.month ==10} selected {/if}>10</option>
						<option value="11" {if $magic.request.month ==11} selected {/if}>11</option>
						<option value="12" {if $magic.request.month ==12} selected {/if}>12</option>
					</select>
					
					<button style="margin-bottom:3px;margin-left:20px" type="submit" class="btn btn-primary btn-sm select"  >Search</button>
			    	
    			</form>
				
				</div>		
				<div id="daysweek">
					<div class="dayweek brn"><p>Sunday</p></div>
					<div class="dayweek"><p>Monday</p></div>
					<div class="dayweek"><p>Tuesday</p></div>
					<div class="dayweek"><p>Wednesday</p></div>
					<div class="dayweek"><p>Thursday</p></div>
					<div class="dayweek"><p>Friday</p></div>
					<div class="dayweek brn"><p>Saturday</p></div>
					
				</div>
				<div id="daysmonth">
<!---------------------------------------- week 1 ---------------------------------------->
					
					{ list module="calendar"  function="getCalendarList" var="loop"  sub_status=request user_id=request   project_id=request month=request year=request dotime1=$_G.dotime1 dotime2=$_G.dotime2 color=request  modules_id=request }
						{foreach from="$loop.list" item="item" key="kkey"}
						<?
								$this->magic_vars['beyond'] = $this->magic_vars['kkey']-$this->magic_vars['loop']['stat'];
								$this->magic_vars['days'] = $this->magic_vars['loop']['days'];
						?>
					{if $kkey %7 ==1}
					<div class="week">
							{/if}
						<div class="day clickable    {if $kkey %7 ==1}  brn {/if} ">
							<div class="daybar"><p>&nbsp;
								{if $beyond>0&& $beyond<=$days}
								{$beyond}<span class="glyphicon glyphicon-plus-sign mission-add click"  onclick="addMission({$kkey},{$beyond})"></span>
								{/if}
								</p></div>
							<div class="dots">
								<ul>
									{if $beyond>0&& $beyond<=$days}
										{if $magic.request.color =='project' || $magic.request.color =='' } 
											{foreach from="$item.project" item="p" key="pkey"}
												<li style="background-color:#{$p}"></li>
											{/foreach}
										{elseif $magic.request.color =='member'}
											{foreach from="$item.user" item="p" key="pkey"}
											<li style="background-color:#{$p}"></li>
											{/foreach}
										{elseif $magic.request.color =='modules'}
											{foreach from="$item.modules" item="p" key="pkey"}
											<li style="background-color:#{$p}"></li>
											{/foreach}
										{/if}
									{/if}
								</ul>
							</div>	
							<!-- slide open -->
							<div class="open" style="display: none;height:700px;">
								<ul class="dragsort {if $beyond>0&& $beyond<=$days} list {/if}" id="list{$kkey}" statx={$kkey}>
									{if $beyond>0&& $beyond<=$days}
									{foreach from="$item.mission" item="val"  key="kkkey"}
									
									<li style="
									{if $val.more =="middle"}
									border-radius:0px;
									
									{elseif $val.more =="first"}
									border-bottom-right-radius:0px;
									border-top-right-radius:0px;
									
									{elseif $val.more =="last"}
									border-bottom-left-radius:0px;
									border-top-left-radius:0px;
									
									{/if}
									{if $magic.request.color =='project' || $magic.request.color =='' } 
									background-color:#{$val.pcolor} 
									{elseif $magic.request.color =='member'}
									background-color:#{$val.ucolor} 
									{elseif $magic.request.color =='modules'}
									background-color:#{$val.mcolor}
									{/if}
									" id="{$val.id}">
										<div>
										<p>
											<span class="mission-name">
												{if $val.name !="empty"}
												{$val.name}
												{/if}
											{if $val.status == 3}
											<span class="glyphicon glyphicon-ok " style="font-size:5px;margin-left:5px"></span>
											{/if}
											</span>
											
											 <span class="mission-user">{$val.uname}</span>
											</p>
											<!--
											{foreach from="$val.submission" item="subval"}
											<p class="calendar-submission">
												- {$subval.name}
											</p>
												{/foreach}
												-->
												{if $val.name !="empty"}
											<p class="calendar-submission">
											<span class="glyphicon glyphicon-plus-sign fr click"  onclick="addSubMission({$val.id},{$kkey})" ></span>
											<span class="glyphicon glyphicon-pencil fr click " onclick="updateMission({$val.id})" ></span>
											{if !$val.submission}
											<span class="glyphicon glyphicon-search fr click " onclick="showMission({$val.id},{$kkey})" ></span>
											{else}
											<span class="glyphicon glyphicon-zoom-in fr click " onclick="showMission({$val.id},{$kkey})" ></span>
											{/if}
											{/if}
											{if $val.more =="only"}
											<label class="glyphicon glyphicon-hand-up fr click "  ></label>
											{/if}
											</p>
											</div>
										</li>
								
							{/foreach}		
								{/if}			
								</ul>
							</div>	
							<!-- slide closed -->
						</div>		
						{if $kkey %7 ==0}
						</div>
						{/if}
								{/foreach}
				{/list}
							
						

				
<!---------------------------------------- week 5 end ---------------------------------------->
				</div>				
			</div>	
			 {include file="right.html"}
			
		
						<input name="list1SortOrder" type="hidden" value="2"/>
		</div>	
		
		
		<script type="text/javascript">
			{literal}
		$(".list").dragsort({
			dragSelector: "label", 
			dragBetween: true, 
			dragEnd: saveOrder, 
			placeHolderTemplate: "<li class='placeHolder'><div></div></li>",
			scrollSpeed: 5
		});
		
		function saveOrder() {
			var statx = $(this).parent().attr('statx');
			var mission_id = $(this).attr('id');
			
			var url ="/?user&q=code/mission/update_ajax"
			
			var res = {
				
				id:mission_id,
				statx:statx
			};
			
		//	alert(res);
		//	return false;
			
			$.post(url,res,function(data)
			{
			
				alert(data);
				if(data!='')
				{
//					$('#myModal2').modal('hide');
					//location.href=jumpUrl;
				}
		
			},'text');
	
//			var data = $("#list6 li").map(function(){
//				return $(this).children().html();
//			}).get();
//			alert(data)
//			$("input[name='list1SortOrder']").val(data.join("|"));
//			alert($("input[name='list1SortOrder']").val());
		};
		
{/literal}
var urls = '{$_U.query_url}';
var project_id =  '{$magic.request.project_id}';
var user_id =  '{$magic.request.user_id}';
var year =  '{$magic.request.year}';
var month =  '{$magic.request.month}';




</script>
	
	
</body></html>